
local skill = require 'types.skill'

local dmg_tips = {
    ['攻击'] = '|cffff9900攻击伤害|r',
    ['技能'] = '|cff00ffff技能伤害|r',
    ['物理'] = '|cffff6600物理伤害|r',
    ['魔法'] = '|cff3366ff魔法伤害|r',
}

function skill.__index:damage_num()
    local hero = self.owner
    if hero then
        return math.ceil(hero:get('攻击') * self.data1/100)
    end
    return 0
end

function skill.__index:dmg_tip()
    local hero = self.owner
    if hero then
        if japi.GetKeyState(KEY.ALT) then
            return self.alt_tip or ('|cffffcc99%0.f%%攻击|r'):format(self.data1)
        else
            return ('|cffffcc99%s|r(|cff00ff00按alt查看公式|r)'):format(format_number1(self:damage_num()))
        end
    end
end

function skill.__index:dmg_ty()
    local str = self['伤害类型']
    return dmg_tips[str]
end


--白圈
ac.hint_white = function(point,area,time)
    local effect = point:effect
    {
        hide_when_remove = true,
        model = [[dea6d556c11037ec0783b7dbbaea9f7f.mdl]],
        size = area/176,
        time = time,
        height = 90,
    }
    return effect
end

--白圈
ac.hint_white2 = function(point,area,time)
    local effect = point:effect
    {
        hide_when_remove = true,
        model = [[range_circle.mdl]],
        size = area/500,
        time = time,
        height = 0,
    }
    return effect
end


--红圈
ac.hint_red = function(point,area,time)
    local time = time or 99999
    local point = point:get_point()
    local effect = point:effect
    {
        hide_when_remove = true,
        model = [[030f7916c9e400e1877b010d6ef5cb08.mdl]],
        size = area/512,
        speed = 1/time,
        time = time,
        height = 90,
    }
    return effect
end

function get_dmgty_tip(v)
    local dmg_tip = {}
    local dp1 = dmg_tips[v['攻击类型']]
    local dp2 = dmg_tips[v['伤害类型']]
    if dp1 then
        table.insert(dmg_tip,dp1)
    end
    if dp2 then
        table.insert(dmg_tip,dp2)
    end
    if v.cool and v.cool>0 and v.skill_type=='抽卡天赋' then
        table.insert(dmg_tip,('冷却%0.f秒'):format(v.cool))
    end
    if #dmg_tip>0 then
        return table.concat(dmg_tip,' ')
    end
end

local spcolor = {
    ['暴击几率'] = '|cffff0000暴击几率|r',
    ['暴击伤害'] = '|cffff0000暴击伤害|r',
    ['攻击'] = '|cffff0000攻击|r',
    ['攻击伤害'] = '|cffff0000攻击伤害|r',
    ['物理伤害'] = '|cffff0000物理伤害|r',
}
function skill.__index:attr_tip1()
    local key = self['属性1']
    return spcolor[key] or ('|cff00ff00%s|r'):format(key)
end

function skill.__index:attr_tip2()
    local key = self['属性2']
    return spcolor[key] or ('|cff00ff00%s|r'):format(key)
end

function skill.__index:attr_tip3()
    local key = self['属性3']
    return spcolor[key] or ('|cff00ff00%s|r'):format(key)
end

function skill.__index:cp_data1()
    if self.data1<1 then
        return ('|cff00ff00%0.1f|r'):format(self.data1)
    end
    return ('|cff00ff00%0.f|r'):format(self.data1)
end
function skill.__index:cp_data2()
    if self.data2<1 then
        return ('|cff00ff00%0.1f|r'):format(self.data2)
    end
    return ('|cff00ff00%0.f|r'):format(self.data2)
end
function skill.__index:cp_data3()
    if self.data3<1 then
        return ('|cff00ff00%0.1f|r'):format(self.data3)
    end
    return ('|cff00ff00%0.f|r'):format(self.data3)
end
function skill.__index:cp_data4()
    if self.data4<1 then
        return ('|cff00ff00%0.1f|r'):format(self.data4)
    end
    return ('|cff00ff00%0.f|r'):format(self.data4)
end
function skill.__index:cp_data5()
    if self.data5<1 then
        return ('|cff00ff00%0.1f|r'):format(self.data5)
    end
    return ('|cff00ff00%0.f|r'):format(self.data5)
end
function skill.__index:cp_data6()
    if self.data6<1 then
        return ('|cff00ff00%0.1f|r'):format(self.data6)
    end
    return ('|cff00ff00%0.f|r'):format(self.data6)
end
function skill.__index:cp_data7()
    if self.data7<1 then
        return ('|cff00ff00%0.1f|r'):format(self.data7)
    end
    return ('|cff00ff00%0.f|r'):format(self.data7)
end